{% extends "base.html" %}
{% block title %}{% endblock %}
{% block content %}
<br>
<div class="layui-body" style="overflow:auto;left:1px">
    <br>
    <ul class="layui-timeline" id="timeList">

    </ul>

    <div class="demoTable">
        <br>
        <form class="layui-form" action="" id="workTable">

            <div class="layui-input-inline">

                <label class="layui-form-label">note：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="note" id="note" placeholder="请输入" style="width:212px">
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-input-inline">
                    <button class="layui-btn layui-btn-normal" id="save" lay-submit lay-filter="formDemo">保存</button>
                </div>
            </div>
        </form>

    </div>
</div>
<script>
    function getRemark(){
        task_name = layui.data('test').task_name;
        $.ajax({
                                    //发出请求
                                    type:"GET",
                                    url:"/result/remark/list",
                                    contentType: 'application/json; charset=utf-8',
                                    dataType:"json",
                                    data:{"task_name":task_name},
                                    success: function(result){
                                        strHtml = "";
                                        result.data.forEach(function(value, index, array) {

                                            timeStr = '<li class="layui-timeline-item">'+
                                                       ' <i class="layui-icon layui-timeline-axis">&#xe63f;</i>'+
                                                       '   <div class="layui-timeline-content layui-text">'+
                                                       '    <h3 class="layui-timeline-title">'+value.last_time+''+
                                                       ' &nbsp;&nbsp;       <span style="color:green">'+value.note+'</span></h3>'+
                                                       '    </div>'+
                                                       ' </li>';

                                            strHtml = strHtml + timeStr;

                                        });
                                        newHtml = '<ul class="layui-timeline" id="timeList">'+strHtml+'</ul>';
                                        $('#timeList').html(newHtml);
                                    }
        });
    }
    layui.use(['table','code'], function(){
          var table = layui.table
          ,form = layui.form;
          var $= layui.jquery;
          //
          getRemark();
          //监听提交
          form.on('submit(formDemo)', function(data){
            note = data.field.note;
            if(note==""){layer.msg("备注不能为空!");return false;}
            task_name = layui.data('test').task_name;

            $.ajax({
                        //发出请求
                        type:"POST",
                        url:"/result/remark/save",
                        contentType: 'application/json; charset=utf-8',
                        dataType:"json",
                        data:JSON.stringify({"task_name":task_name,"note":note}),
                        success: function(result){
                            layer.msg("添加成功!");
                            getRemark();
                            $('#note').val("");
                        }
            });

            return false;
          });
          form.render();

    });

</script>
{% endblock %}